package com.wuzhipeng.heart.user.config; //创建一个bloom过滤器

import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
     * 布隆过滤器配置
     */
    @Configuration
    public class RBloomFilterConfiguration {

        /**
         * 防止用户注册查询数据库的布隆过滤器
         */
        @Bean
        public RBloomFilter<String> userRegisterCachePenetrationBloomFilter(RedissonClient redissonClient) {
            RBloomFilter<String> cachePenetrationBloomFilter = redissonClient.getBloomFilter("userRegisterCachePenetrationBloomFilter");
            cachePenetrationBloomFilter.tryInit(100000, 0.001);//长度和误判率
            return cachePenetrationBloomFilter;
        }
        /**
         * 防止咨询师注册查询数据库的布隆过滤器
         */
        @Bean
        public RBloomFilter<String> therapistRegisterCachePenetrationBloomFilter(RedissonClient redissonClient) {
            RBloomFilter<String> cachePenetrationBloomFilter = redissonClient.getBloomFilter("therapistRegisterCachePenetrationBloomFilter");
            cachePenetrationBloomFilter.tryInit(100000, 0.001);//长度和误判率
            return cachePenetrationBloomFilter;
        }
}